<?php


class Index
{
	//导入excel
	public function import()
	{
		$tmp_file = $_FILES['file_stu']['tmp_name'];
		$file_types = explode ( ".", $_FILES ['file_stu'] ['name'] );
		$file_type = $file_types [count ( $file_types ) - 1];
		$savePath = './Excel/';
		$str = date ('Ymdhis'); 
		$file_name = $str . "." . $file_type;
		copy($tmp_file,$savePath.$file_name);
		require_once('./phpexcel.php');
		$excel = new ExcelToArray();
		$res = $excel->read($savePath.$file_name);
		echo "<br/>";
		var_dump($res);
		echo "<br/>";
	}

	public function export()
	{
		$dataResult = array(
			array('吕', '23', '男', '7-26'),
			array('张', '21', '男', '7-23')
		);
		$headTitle = "档案"; 
		$title = "档案记录"; 
		$headtitle= "<tr style='height:50px;border-style:none;><th border=\"0\" style='height:60px;width:270px;font-size:22px;' colspan='11' >{$headTitle}</th></tr>"; 
		$titlename = "<tr> 
			<th style='width:70px;' >姓名</th> 
			<th style='width:70px;' >年龄</th> 
			<th style='width:70px;' >性别</th> 
			<th style='width:70px;' >生日</th> 
			</tr>"; 
		$filename = $title.".xls"; 
		require_once('./phpexcel.php');
		$excel = new ExcelToArray();
		$data = $excel->export($dataResult,$titlename,$headtitle,$filename);
	}

}

$aa = new Index();
$aa->export();
